package com.bw.zh.view

import android.os.Bundle
import android.view.LayoutInflater
import android.widget.Button
import android.widget.TextView
import com.bw.zg2.base.BaseViewBindingActivity
import com.bw.zh.R
import com.bw.zh.databinding.ActivityGoodsDetailBinding
import com.google.android.material.bottomsheet.BottomSheetDialog

class GoodsDetailActivity :
    BaseViewBindingActivity<ActivityGoodsDetailBinding>(R.layout.activity_goods_detail) {
    override fun initData() {
    }

    override fun initView(savedInstanceState: Bundle?) {

        dataBinding.tvChose.setOnClickListener {
            //弹出底部弹框
            val bottomDialog = BottomSheetDialog(this@GoodsDetailActivity)
            val view = LayoutInflater.from(this@GoodsDetailActivity)
                .inflate(R.layout.bottom_dialog_layout, null)
            bottomDialog.setContentView(view)
            val tvClose = view.findViewById<TextView>(R.id.tv_close)
            val tvP = view.findViewById<TextView>(R.id.tv_plus)
            val tvNum = view.findViewById<TextView>(R.id.tv_num)
            val tvAdd = view.findViewById<TextView>(R.id.tv_add)
            val btn = view.findViewById<Button>(R.id.btn)
            var num = 1;
            tvClose.setOnClickListener {
                //关闭底部弹框
                bottomDialog.dismiss()
            }
            btn.setOnClickListener {
                //关闭底部弹框
                bottomDialog.dismiss()
            }
            tvP.setOnClickListener {
                if (num > 0) {
                    num--
                    tvNum.text = num.toString()
                }
            }

            tvAdd.setOnClickListener {
                num++
                tvNum.text = num.toString()
            }
            //显示弹框
            bottomDialog.show()
        }
    }
}